package com.easy.controller;

import com.easy.bean.Sizes;
import com.easy.service.SizesService;
import com.easy.util.Page;
import com.easy.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("sizes")
@CrossOrigin
public class SizesController {
    @Autowired
     SizesService sizesService;
    @PostMapping
    public Result add(@RequestBody Sizes sizes){
        Object obj= sizesService.add(sizes);
        return Result.success("添加成功",obj);
    }
    @DeleteMapping("{id}")
    public Result delete(@PathVariable("id") Integer id){
        int obj= sizesService.del(id);
        return Result.success("删除成功",obj);
    }
    @PutMapping
    public Result edit(@RequestBody Sizes sizes){
        Object obj=sizesService.edit(sizes);
        return Result.success("编辑信息成功",obj);
    }
    @GetMapping("list")
    public Result list(Sizes sizes){
        List<Sizes> list=sizesService.all(sizes);
        return Result.success(list);
    }
    @GetMapping("{id}")
    public Result select(@PathVariable("id") Integer id){
        Object obj=sizesService.one(id);
        return Result.success(obj);
    }
    @GetMapping("page")
    public Result page(Page page, Sizes sizes){
        sizesService.page(page,sizes);
        return Result.success(page);
    }
}
